/**
 * <p>文件名:		MockConsumeMessage.java</p>
 * <p>版权:		CopyrightTag</p>
 * <p>公司:		千方集团CTFO</p>
 * @author		周华彬(zhouhuabin@ctfo.com, zhou_hua_bin@163.com)
 */

package com.caits.lbs.framework.sms;

import java.util.Enumeration;

import javax.jms.JMSException;
import javax.jms.Message;

import org.apache.log4j.Logger;

import com.caits.lbs.framework.log.CommonLogFactory;
import com.caits.lbs.framework.services.sms.IConsumeMessage;
import com.caits.lbs.framework.services.sms.MessageSMS;

/**
 * <p>
 * MockConsumeMessage
 * </p>
 * <p>
 * 用途：TODO
 * </p>
 * 
 * @author 周华彬(zhouhuabin@ctfo.com, zhou_hua_bin@163.com)
 * @version 0.0.1 2013-1-18
 *          <table style="border:1px solid gray;">
 *          <tr>
 *          <th width="100px">版本号</th>
 *          <th width="100px">动作</th>
 *          <th width="100px">修改人</th>
 *          <th width="100px">修改时间</th>
 *          </tr>
 *          <!-- 以 Table 方式书写修改历史 -->
 *          <tr>
 *          <td>0.0.0</td>
 *          <td>创建类</td>
 *          <td>zhb</td>
 *          <td>2013-1-18 下午3:22:13</td>
 *          </tr>
 *          <tr>
 *          <td>0.0.1</td>
 *          <td>创建类</td>
 *          <td>zhb</td>
 *          <td>2013-1-18 下午3:22:13</td>
 *          <td>0.0.2</td>
 *          <td>修改类</td>
 *          <td>xxx</td>
 *          <td>x年x月x日</td>
 *          </tr>
 *          </table>
 */
public class MockConsumeMessage implements IConsumeMessage {

	private Logger log = CommonLogFactory.getLog();

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.caits.lbs.framework.services.sms.IConsumeMessage#onMessage(java.lang
	 * .Object)
	 */
	@Override
	public void onMessage(Object message) {
		try {
			if(message instanceof Message){
				Message msg= (Message)message;
				Enumeration<Object> enumer=msg.getPropertyNames();
				while(enumer.hasMoreElements()){
					Object obj=enumer.nextElement();
					Object value=null;
					if(obj instanceof String){
						value=msg.getObjectProperty((String)obj);
					}
					log .info("消费者我收到消息了,obj.class="+obj.getClass().getCanonicalName()+",value="+value);
				}
			}else if(message instanceof MessageSMS){
				MessageSMS msg=(MessageSMS)message;
				log .info("消费者我收到消息了,head="+msg.getHead()+",body="+msg.getBody());
			}else if(message instanceof String){
				String value=(String)message;
				log .info("消费者我收到消息了,value="+value);
			}
		} catch (JMSException e) {
			log.error("获取消息时异常,msg="+message.hashCode(), e);
		}
			
	}

}
